#ifndef PRUEBABUFFER_H_
#define PRUEBABUFFER_H_

#include "../Buffer.h"

void pruebaBuffer1() 
{
	Toolkit::Buffer b = Toolkit::Buffer(4, Toolkit::BINARIO);
	
	stringstream stream;	
	float valor, leido;
	
	valor = 125.633;
	stream.str("");
	stream.write((char*)&valor, sizeof(float));
	b.guardarDato(stream);
	
	valor = 22.3;
	stream.str("");
	stream.write((char*)&valor, sizeof(float));
	b.guardarDato(stream);
	
	valor = 11.111;
	stream.str("");
	stream.write((char*)&valor, sizeof(float));
	b.guardarDato(stream);
	
	valor = 0.00033;
	stream.str("");
	stream.write((char*)&valor, sizeof(float));
	b.guardarDato(stream);
	
	b.recuperarDato(2, stream);
	stream.read((char*)&leido, sizeof(float));
	std::cout << leido << std::endl;	
	
	valor = 77777.77;
	stream.str("");
	stream.write((char*)&valor, sizeof(float));
	b.guardarDato(stream, 2);
	
	b.recuperarDato(2, stream);
	stream.read((char*)&leido, sizeof(float));
	std::cout << leido << std::endl;	
	
	
}

void pruebaBuffer2() 
{
	Toolkit::Buffer b = Toolkit::Buffer(4, Toolkit::BINARIO);
	
	stringstream stream;	
	float valor, leido;
	
	valor = 125.633;
	stream.str("");
	stream.write((char*)&valor, sizeof(float));
	b.guardarDato(stream);
	
	valor = 22.3;
	stream.str("");
	stream.write((char*)&valor, sizeof(float));
	b.guardarDato(stream);
	
	valor = 11.111;
	stream.str("");
	stream.write((char*)&valor, sizeof(float));
	b.guardarDato(stream);
	
	valor = 0.00033;
	stream.str("");
	stream.write((char*)&valor, sizeof(float));
	b.guardarDato(stream);
	
	b.eliminarDato(1, stream);
	stream.read((char*)&leido, sizeof(float));
	std::cout << leido << std::endl;
	
	b.eliminarDato(2, stream);
	stream.read((char*)&leido, sizeof(float));
	std::cout << leido << std::endl;
	
	valor = 77777.77;
	stream.str("");
	stream.write((char*)&valor, sizeof(float));
	b.guardarDato(stream, 0);
	
	b.recuperarDato(0, stream);
	stream.read((char*)&leido, sizeof(float));
	std::cout << leido << std::endl;
	
	valor = 111111.1;
	stream.str("");
	stream.write((char*)&valor, sizeof(float));
	b.guardarDato(stream);
	
	valor = 222222.2;
	stream.str("");
	stream.write((char*)&valor, sizeof(float));
	b.guardarDato(stream);
	
	valor = 4444444.1;
	stream.str("");
	stream.write((char*)&valor, sizeof(float));
	b.guardarDato(stream);
	
	b.recuperarDato(1, stream);
	stream.read((char*)&leido, sizeof(float));
	std::cout << leido << std::endl;
	
	b.recuperarDato(2, stream);
	stream.read((char*)&leido, sizeof(float));
	std::cout << leido << std::endl;
	
	b.recuperarDato(4, stream);
	stream.read((char*)&leido, sizeof(float));
	std::cout << leido << std::endl;
	
	std::cout << b.cantElementos() << std::endl;
}

void pruebaStream() 
{
	stringstream stream;
	char aux[] = "pepeArtigas";
	stream.write(aux, sizeof(aux));
	
	cout << stream.str() << endl;
	
	char aux2[] = "joseArtigas";
	stream.seekp(0, ios_base::beg);
	stream.write(aux2, sizeof(aux));
	
	cout << stream.str() << endl;
	
}



#endif /*PRUEBABUFFER_H_*/
